// 导入axios实例
import httpRequest from '../request/index'


// 获取电影全部年份
export function getYears() {
    return httpRequest({
        url: '/movie/years',
        method: 'get',
    });
}


// 获取全部电影
export function getAll() {
    return httpRequest({
        url: '/movie/all',
        method: 'get',
    });
}

// 获取全部电影（不分组）
export function getAllMovie() {
    return httpRequest({
        url: '/movie/listall',
        method: 'get',
    });
}


// 分页获取电影列表数据
export function getList(pageSize, pageNum) {
    return httpRequest({
        url: `/movie?pageSize=${pageSize}&pageNum=${pageNum}`,
        method: 'get',
    });
}


// 获取电影全部集数链接
export function getMovieLinks(id) {
    return httpRequest({
        url: `/movie/vlist?mid=${id}`,
        method: 'get',
    });
}


// 添加电影
export function addMovie(movie) {
    return httpRequest({
        baseURL: '/admin',
        url: `/movie/add`,
        method: 'post',
        data: movie,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 编辑电影
export function editMovie(id, movie) {
    return httpRequest({
        baseURL: '/admin',
        url: `/movie/edit/${id}`,
        method: 'put',
        data: movie,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 删除电影
export function deleteMovie(id) {
    return httpRequest({
        baseURL: '/admin',
        url: `/movie/${id}`,
        method: 'delete',
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}



// 写评语
export function doMovieComment(id, comment) {
    return httpRequest({
        baseURL: '/admin',
        url: `/movie/comment/${id}`,
        method: 'post',
        data: comment,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}
